package cn.cgy.fate;

import com.geccocrawler.gecco.GeccoEngine;
import com.geccocrawler.gecco.annotation.Gecco;
import com.geccocrawler.gecco.annotation.HtmlField;
import com.geccocrawler.gecco.annotation.Text;
import com.geccocrawler.gecco.request.HttpGetRequest;
import com.geccocrawler.gecco.spider.HtmlBean;

import java.util.List;

@Gecco(matchUrl = "https://kaijiang.500.com/ssq.shtml",
        pipelines = {"getResultSpiderPipeline"})
public class GetResultSpider implements HtmlBean {

    @HtmlField(cssPath = "body > div.wrap > div.kj_main01 > div.kj_main01_right > div.kjxq_box02 > div:nth-child(2) > table:nth-child(1) > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(1) > td:nth-child(2) > div > ul > li")
    private List<Integer> numberList;

    @HtmlField(cssPath = "body > div.wrap > div.kj_main01 > div.kj_main01_right > div.kjxq_box02 > div:nth-child(2) > table:nth-child(1) > tbody > tr:nth-child(1) > td > span.span_right")
    @Text
    private String openInfo;

    @HtmlField(cssPath = "#change_date")
    private String period;

    public List<Integer> getNumberList() {
        return numberList;
    }

    public void setNumberList(List<Integer> numberList) {
        this.numberList = numberList;
    }

    public String getOpenInfo() {
        return openInfo;
    }

    public void setOpenInfo(String openInfo) {
        this.openInfo = openInfo;
    }

    public String getPeriod() {
        return period;
    }

    public void setPeriod(String period) {
        this.period = period;
    }

    public static void main(String[] args) {

        HttpGetRequest start = new HttpGetRequest("https://kaijiang.500.com/ssq.shtml");

        start.setCharset("GBK");

        GeccoEngine
                .create()
                .classpath("cn.cgy.fate")
                .start(start)
                .thread(1)
                .interval(1000)
                .run();
    }
}
